package org.tgcloud.group.web.controller.manager;

import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.web.bind.annotation.*;
import org.tgcloud.group.core.APPResultMessage;
import org.tgcloud.group.core.custom.Permissions;
import org.tgcloud.group.core.session.Session;
import org.tgcloud.group.service.manager.OtherProjectService;
import org.tgcloud.group.web.controller.dto.otherProject.OtherProjectManageMsgDTO;
import org.tgcloud.group.web.controller.req.otherProject.OtherProjectIdReq;
import org.tgcloud.group.web.controller.req.otherProject.OtherProjectReq;
import java.util.List;

@Api(tags = "其他类型项目相关的接口")
@RestController
@RequestMapping("/manager/pc/user")
@EnableAutoConfiguration
public class OtherProjectController extends ManageAPPBaseController{
    @Autowired
    private OtherProjectService otherProjectService;


    //    @LogRecords(value = "其他项目列表")
    @Permissions("otherProject:view")
    @ApiOperation(value = "其他项目列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "token", required = true, dataType = "string")
    })
    @ResponseBody
    @RequestMapping(value = "/getOtherProjectList", method = RequestMethod.POST)
    public APPResultMessage getOtherProjectList(@ModelAttribute("session") Session session,
                                            @RequestParam(required = false) Integer pageNum,
                                            @RequestParam(required = false) Integer pageSize,
                                            @RequestParam(required = false) String keyword
    ){
        return otherProjectService.getOtherProjectList(pageNum, pageSize, keyword);
    }


    @Permissions("otherProject:add")
    @ApiOperation(value = "其他项目新增")
    @ApiImplicitParams({
    })
    @ApiResponses({
            @ApiResponse(code = 2000, message = "出现异常，及时通知后台")
    })
    @ResponseBody
    @PostMapping(value = "/addOtherProject")
    public APPResultMessage<Object, List> addOtherProject(@ModelAttribute("session")Session session,
                                                          @RequestBody OtherProjectReq req) {
        return otherProjectService.addOtherProject(req, session.getUserId());
    }


    @Permissions("otherProject:del")
    @ApiOperation(value = "其他项目删除")
    @ApiImplicitParams({
    })
    @ApiResponses({
            @ApiResponse(code = 2000, message = "出现异常，及时通知后台")
    })
    @ResponseBody
    @PostMapping(value = "/delOtherProject")
    public APPResultMessage<Object, List> delManageProject(
                                                           @ModelAttribute("session")Session session,
                                                           @RequestBody OtherProjectIdReq req) {
        return otherProjectService.delOtherProject(req.getId());
    }



    @ApiOperation(value = "其他项目-详情")
    @ApiImplicitParams({
    })
    @ApiResponses({
            @ApiResponse(code = 2000, message = "出现异常，及时通知后台")
    })
    @ResponseBody
    @PostMapping(value = "/viewOtherProjectMsg")
    public APPResultMessage<OtherProjectManageMsgDTO, List> viewOtherProjectMsg(@RequestBody OtherProjectIdReq req) {
        return otherProjectService.viewOtherProjectMsg(req.getId());
    }




}
